package com.vint.common;

import java.util.Random;

/*
 * 二叉树节点
 */
public class TreeNode {
    public static int VAL_MAX = 10000;
    public static Random random = new Random();
    public int val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(int x) {
        val = x;
    }
    public static TreeNode mockTree(){
        TreeNode root = mockNode();
        if (null != root) {
            root.left = mockTree();
            root.right = mockTree();
        }
        return root;
    }
    public static TreeNode mockNode(){
        boolean leaf = random.nextBoolean();
        TreeNode root = null;
        if (leaf) {
            root = new TreeNode(random.nextInt(VAL_MAX));
        }
        return root;
    }

    public static TreeNode mockBinarySearchTree(){
        TreeNode root = new TreeNode(5);
        root.left = new TreeNode(3);
        root.left.left = new TreeNode(2);
        root.left.right = new TreeNode(4);
        root.right= new TreeNode(9);
        return root;
    }

    public static TreeNode mockSpecific1(){
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(3);
        root.left.left = new TreeNode(2);
        root.left.right = new TreeNode(2);
        return root;
    }
    public static TreeNode mockSpecific2(){
        TreeNode root = new TreeNode(2);
        root.left = new TreeNode(1);
        root.right= new TreeNode(3);
        root.left.right = new TreeNode(4);
        root.right.right = new TreeNode(7);
        return root;
    }

    public static void main(String[] args){
        TreeNode root1 = mockTree();
        TreeNode root2 = mockTree();
    }
}
